package top.anydata.lifeofcode.lifesystem.web.responses.admin;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 功能描述: API响应标准格式
 *
 * @author <a href="mailto:caingao@anydata.top">CainGao</a>
 * @version V_1.0
 * @date 2024/2/6 4:49 PM
 */
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class ApiResponse<T> {
    private int code;
    private String message;
    private T data;

    public static <T> ApiResponse<T> success(T data){
        return ApiResponse.<T>builder().code(200).data(data).build();
    }

    public static <T> ApiResponse<T> fail(int code, String message){
        return ApiResponse.<T>builder().code(code).message(message).build();
    }

}
